<template>
  <div id="zhfxyp" style="padding-top:10px">
      <div v-if="showgbjd">
          <el-tooltip class="item" effect="dark" content="导出干部监督信息" placement="top">
            <el-button type="success" icon="el-icon-download" @click="exportword">导出</el-button>
          </el-tooltip>
        <mygbjd v-bind:personId="personId" v-bind:title="'干部档案审核情况'" v-bind:objtype="myobjtypes.COMMON_TYPE_DANGANSHENHE"></mygbjd>
        <mygbjd v-bind:personId="personId" v-bind:title="'个人事项报告查核'" v-bind:objtype="myobjtypes.COMMON_TYPE_GERENSHIXIANGHECHA"></mygbjd>
        <mygbjd v-bind:personId="personId" v-bind:title="'纪检监察部门意见'" v-bind:objtype="myobjtypes.COMMON_TYPE_JIJIANJIANCHA"></mygbjd>
        <mygbjd v-bind:personId="personId" v-bind:title="'举报及核实情况'" v-bind:objtype="myobjtypes.COMMON_TYPE_JUBAO"></mygbjd>
        <mygbjd v-bind:personId="personId" v-bind:title="'公示情况'" v-bind:objtype="myobjtypes.COMMON_TYPE_GONGSHI"></mygbjd>
        <mygbjd v-bind:personId="personId" v-bind:title="'一报告两评议结果（领导班子）'" v-bind:objtype="myobjtypes.COMMON_TYPE_YIBAOGAOLIANGPINGYI_BANZI"></mygbjd>
        <mygbjd v-bind:personId="personId" v-bind:title="'一报告两评议结果（个人）'" v-bind:objtype="myobjtypes.COMMON_TYPE_YIBAOGAOLIANGPINGYI_GEREN"></mygbjd>
      </div>
      <div v-else style="line-height:40px;font-size:var(--size14);padding-left:10px">
        <el-button type="primary" icon="el-icon-circle-plus-outline" :loading="addloading" @click="addZhfxyp">开始填写干部监督信息</el-button>
      </div>
  </div>
</template>
<script>
import * as objtypes from '@/constvalue/commonvalues'
import mygbjd from '@/person/mygbjd.vue'
export default {
  components: {
    mygbjd
  },
  watch: {
    personId: {
      handler (val) {
        this.personId = val
        this.getZhfxypList(val)
      },
      // 代表在wacth里声明了firstName这个方法之后立即先去执行handler方法
      immediate: true
    },
    personname: {
      handler (val) {
        this.personname = val
      },
      // 代表在wacth里声明了firstName这个方法之后立即先去执行handler方法
      immediate: true
    },
    unitname: {
      handler (val) {
        this.unitname = val
      },
      // 代表在wacth里声明了firstName这个方法之后立即先去执行handler方法
      immediate: true
    }
  },
  props: {
    personId: '',
    personname: '',
    unitname: ''
  },
  data () {
    return {
      myobjtypes: objtypes,
      zhfxypDetail: {},
      zhfxypList: [],
      addloading: false,
      mygbda: {},
      mygrsx: {},
      myjjjc: {},
      myjbhs: {},
      mygongshi: {},
      mybanzi: {},
      mygeren: {},
      gbdacontent: '',
      grsxcontent: '',
      jjjccontent: '',
      jbhscontent: '',
      gongshicontent: '',
      banzicontent: '',
      gerencontent: '',
      showgbjd: false
    }
  },
  methods: {
    exportword () {
      window.open(this.$http.defaults.baseURL + 'common/ganbujiandu/wordfile/' + this.personId)
    },
    addZhfxyp () {
      let para = {
        idnumber: this.personId,
        unitname: this.unitname,
        name: this.personname
      }
      let _this = this
      this.addloading = true
      this.$http
        .post(`/common/addganbujiandu/`, para)
        .then(function (response) {
          if (response.data.success === true) {
            _this.banzicontent = ''
            _this.gerencontent = ''
            _this.getZhfxypList(_this.personId)
          } else {
            _this.$message({
              message: response.data.message,
              type: 'error'
            })
          }
          _this.addloading = false
        })
        .catch(function (error) {
          _this.$message({
            message: '添加失败:' + error,
            type: 'error'
          })
          _this.addloading = false
        })
    },
    getZhfxypList (id, flag) {
      var _this = this
      this.$http
        .get(`/common/haveganbujiandu/` + id)
        .then(function (response) {
          _this.showgbjd = response.data
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    }
  },
  mounted () {
  }
}
</script>
<style>
#zhfxyp .el-table td, .el-table th{
  padding:2px 0;
}
#zhfxyp .el-textarea__inner{
  font-size:var(--size18) !important;
  color:#000 !important;
}
</style>
